﻿using System.Collections.Generic;
using System.Numerics;
using Newtonsoft.Json;

namespace T.FAS.Runtime.Metadata.Entity.MF
{
    public class WorkflowNode : NodeBase
    {
        [JsonProperty("data")]
        public new WorkflowNodeData Data { get; set; }
        public override string RefMetaDataID
        {
            get
            {
                return Data.WorkflowID;
            }
        }

        public override string RefMetaDataType
        {
            get
            {
                return "microflow";
            }
        }
    }

   
    public class WorkflowNodeData
    {
        [JsonProperty("label")]
        public string Label { get; set; }

        [JsonProperty("description")]
        public string Description { get; set; }
        [JsonProperty("versionStrategy")]
        public string VersionStrategy { get; set; }
        [JsonProperty("executionMode")]
        public string ExecutionMode { get; set; }
        [JsonProperty("timeoutMs")]
        public int TimeoutMs { get; set; }
        [JsonProperty("errorPolicy")]
        public string ErrorPolicy { get; set; }

        [JsonProperty("enableErrorOutput")]
        public bool EnableErrorOutput { get; set; }
        [JsonProperty("selectedEndNodeId")]
        public string SelectedEndNodeId { get; set; }
        [JsonProperty("executionStatus")]
        public string ExecutionStatus { get; set; }
        [JsonProperty("status")]
        public string Status { get; set; }
        [JsonProperty("referencedFlowId")]
        public string WorkflowID { get; set; }
        [JsonProperty("referencedFlowCode")]
        public string WorkflowCode { get; set; }

        [JsonProperty("referencedFLowName")]
        public string WorkflowName { get; set; }

        [JsonProperty("inputFields")]
        public List<WorkflowInputField> InputFields { get; set; }

        [JsonProperty("outputFields")]
        public List<WorkflowOutField> OutputFields { get; set; }
        [JsonProperty("error_strategy")]
        public string ErrorStrategy { get; set; }

        [JsonProperty("default_value")]
        public List<UserVariable> DefaultValues { get; set; }
        [JsonProperty("cachedIOSchema")]
        public CachedIOSchema CachedIOSchema { get; set; }
        [JsonProperty("config")]
        public ConfigNode Config { get; set; }
        [JsonProperty("waitPolicy")]
        public Dictionary<string,object> WaitPolicy { get; set; }
        [JsonProperty("portMarkup")]
        public List<PortMarkup> PortMarkup { get; set; }
    }
    public class PortMarkup
    {
        [JsonProperty("selector")]
        public ConfigNode Selector { get; set; }
        [JsonProperty("tagName")]
        public ConfigNode TagName { get; set; }

    }
    public class WorkflowOutField
    {
        [JsonProperty("subflowVariable")]
        public SubVariableNodeInfo SubflowVariable { get; set; }
        [JsonProperty("variable")]
        public string Variable { get; set; }
        [JsonProperty("variableId")]
        public string VariableID { get; set; }
        [JsonProperty("valueType")]
        public string ValueType { get; set; }
        [JsonProperty("variableValueId")]
        public string VariableValueID { get; set; }
        [JsonProperty("variableValue")]
        public string VariableValue { get; set; }
        [JsonProperty("dataType")]
        public string DataType { get; set; }
        [JsonProperty("type")]
        public string Type { get; set; }
    }
    public class WorkflowInputField
    {
        [JsonProperty("variable")]
        public string Variable { get; set; }
        [JsonProperty("variableId")]
        public string VariableId { get; set; }
      
        [JsonProperty("valueType")]
        public string ValueType { get; set; }
        [JsonProperty("constantValue")]
        public string ConstantValue { get; set; }
        [JsonProperty("variableValueId")]
        public string VariableValueID { get; set; }
        [JsonProperty("variableValue")]
        public string VariableValue { get; set; }
        [JsonProperty("variableNodeId")]
        public string VariableNodeID { get; set; }
        [JsonProperty("variableType")]
        public string VariableType { get; set; }
        [JsonProperty("dataType")]
        public string DataType { get; set; }
    }
    public class SubVariableNodeInfo
    {
        [JsonProperty("endNodeId")]
        public string EndNodeID { get; set; }
        [JsonProperty("id")]
        public string ID { get; set; }
        [JsonProperty("variable")]
        public string Variable { get; set; }
        [JsonProperty("label")]
        public string Label { get; set; }
        [JsonProperty("valueType")]
        public string ValueType { get; set; }
        [JsonProperty("type")]
        public string Type { get; set; }
        [JsonProperty("variableNodeId")]
        public string VariableNodeID { get; set; }
        [JsonProperty("variableType")]
        public string VariableType { get; set; }
        [JsonProperty("variableValue")]
        public string VariableValue { get; set; }
    }
    public class Input
    {
        [JsonProperty("name")]
        public string Name { get; set; }
        [JsonProperty("type")]
        public string Type { get; set; }
        [JsonProperty("required")]
        public bool Required { get; set; }
        [JsonProperty("description")]
        public string Description { get; set; }
        [JsonProperty("id")]
        public string ID { get; set; }
    }
    public class Output
    {
       
    }
    public class CachedIOSchema
    {
        [JsonProperty("inputs")]
        public List<Input> Inputs { get; set; }
        [JsonProperty("outputs")]
        public List<Output> Outputs { get; set; }
    }
    public class ConfigNode
    {
        [JsonProperty("enableErrorOutput")]
        public bool EnableErrorOutput { get; set; }
        [JsonProperty("errorPolicy")]
        public string ErrorPolicy { get; set; }
        [JsonProperty("executionMode")]
        public string ExecutionMode { get; set; }
        [JsonProperty("inputMapping")]
        public Dictionary<string, object> InputMapping { get; set; }
        [JsonProperty("outputMapping")]
        public Dictionary<string,object> OutputMapping { get; set; }
        [JsonProperty("referencedFlowId")]
        public string ReferencedFlowId { get; set; }
        [JsonProperty("timeoutMs")]
        public int TimeoutMs { get; set; }
        [JsonProperty("versionStrategy")]
        public string VersionStrategy { get; set; }
    }
}
